package m.fun.model;

import m.base.model.UserInfo;
import m.common.model.*;
import m.common.model.type.FieldType;
import m.common.model.util.ModelQueryList;
import m.common.model.util.QueryCondition;
import m.store.model.StoreGoods;

import java.util.List;
import java.util.stream.Collectors;

@TableMeta(name = "tf_goods_offer", description = "商品报价")
public class GoodsOffer extends Model implements MigrationModel {
    @Override
    public List<String> migrationOidList(String storeOid) throws Exception {
        return ModelQueryList.getModelList(this.getClass(),new String[]{"oid"},null,
                        QueryCondition.eq("user.store.oid",storeOid))
                .stream().map(Model::getOid).collect(Collectors.toList());
    }
    @LinkTableMeta(name="user_oid",table= UserInfo.class,description="所属用户")
    private UserInfo user;
    @LinkTableMeta(name="goods_oid",table= StoreGoods.class,description="商品")
    private StoreGoods goods;
    @FieldMeta(name="title",type= FieldType.STRING,length=200,description="展示名称")
    private String title;
    @FieldMeta(name="color",type= FieldType.STRING,length=20,description="颜色",dictType = "color")
    private String color;
    @FieldMeta(name="index_txt",type= FieldType.STRING,length=20,description="展示标识",dictOption = "N:无,A:热门,B:新品,C:精品")
    private String indexTxt;
    @FieldMeta(name="price_txt",type= FieldType.STRING,length=20,description="展示价格")
    private String priceTxt;

    public String getTitle() {
        return title;
    }

    public void setTitle(String title) {
        this.title = title;
    }

    public UserInfo getUser() {
        return user;
    }

    public void setUser(UserInfo user) {
        this.user = user;
    }

    public StoreGoods getGoods() {
        return goods;
    }

    public void setGoods(StoreGoods goods) {
        this.goods = goods;
    }

    public String getColor() {
        return color;
    }

    public void setColor(String color) {
        this.color = color;
    }

    public String getIndexTxt() {
        return indexTxt;
    }

    public void setIndexTxt(String indexTxt) {
        this.indexTxt = indexTxt;
    }

    public String getPriceTxt() {
        return priceTxt;
    }

    public void setPriceTxt(String priceTxt) {
        this.priceTxt = priceTxt;
    }
}
